If you are looking for a way to automate exploit testing, or simply do not want to use an interactive interface, msfcli may be the solution. This interface takes a match string as the first parameter, followed by the options in a VAR=VAL format, and finally an action code to specify what should be done. The match string is used to determine which exploit you want to launch; if more than one module matches, a list of possible modules will be provided.
The action code is a single letter; S for summary, O for options, A for advanced options, P for payloads, T for targets, C to try a vulnerability check, and E to exploit. The saved environment will be loaded and used at startup, allowing you to configure convenient default options in the Global environment of msfconsole, save them, and take advantage of them in the msfcli interface.